package item.inkcloud.jwtservice.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import item.inkcloud.jwtservice.service.JwtService;
import item.inkcloud.jwtservice.utils.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/jwt")
@RestController
public class JwtController {

    @Autowired
    JwtService jwtService;



    @RequestMapping("/getToken")
    String getToken(@RequestParam("userid") String userid){

        String token = jwtService.getToken(userid);

        return token;

    }

    @PostMapping("/checkToken")
    int checkToken(@RequestBody JSONObject jsonPara){

        String userid =(String)jsonPara.get("userid");

        String token = (String) jsonPara.get("token");

        int status = jwtService.checkToken(token,userid);

        return status;

    }

}
